package com.sy.olddriver.dao.impl;

import com.sy.olddriver.dao.CategoryDao;
import com.sy.olddriver.entity.Category;
import com.sy.olddriver.utils.DBUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

public class CategoryDaoImpl implements CategoryDao {
    private QueryRunner runner = DBUtils.getRunner();

    @Override
    public List<Category> getSubCategoriesByParentId(Integer parentId) {
        try {
            return runner.query("select * from category where parentid=?", new BeanListHandler<>(Category.class), parentId);
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return null;
    }
}
